package com.hqyj.controller;


import com.hqyj.pojo.TbParkingUse;
import com.hqyj.service.TbParkingUseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * <p>
 * 车位使用表 前端控制器
 * </p>
 *
 * @author gp
 * @since 2021-09-26
 */
@RestController
@RequestMapping("/tb-parking-use")
public class TbParkingUseController {

    @Autowired
    private TbParkingUseService tbParkingUseService;

    /**
     * 管理员查看车位使用情况
     * 127.0.0.1:8080/tb-parking-use/parkUses---get
     * @param tbParkingUse
     * @return
     */
    @GetMapping(value = "parkUses")
    public HashMap<String, Object> listParkUse(TbParkingUse tbParkingUse){
        return tbParkingUseService.listParkUse(tbParkingUse);
    }


    /**
     * 业主新增车辆使用情况
     * 127.0.0.1:8080/tb-parking-use/insertParkUse--post
      {"communityName":"海棠苑","communityId":"1","code":"1","carNumber":"渝A111111","ownerName":"阳桑","ownerId":"1",
     "telephone":"12345678977","useType":"1","totalFee":"5000"}
     * param tbParkingUse
     * @return
     */
    @PostMapping(value = "insertParkUse",consumes = "application/json")
    public HashMap<String, Object> insertParkUse(@RequestBody TbParkingUse tbParkingUse){
        return  tbParkingUseService.insertParkUse(tbParkingUse);
    }

    /**
     * 业主购买车位
     * 127.0.0.1:8080/tb-parking-use/buyParkUse---post
     * @param tbParkingUse
     * @return
     */
    @PostMapping(value = "buyParkUse", consumes = "application/json")
    public HashMap<String, Object> buyParkUse(@RequestBody TbParkingUse tbParkingUse){
     return  tbParkingUseService.buyParkUse(tbParkingUse);
    }


    /**
     * 业主开始停车
     * 127.0.0.1:8080/tb-parking-use/startPark---post
     * @param tbParkingUse
     * @return
     */
    @PostMapping(value = "startPark",consumes = "application/json")
    public HashMap<String, Object> startPark(@RequestBody TbParkingUse tbParkingUse){
        return  tbParkingUseService.startPark(tbParkingUse);
    }

    /**
     * 业主结束停车
     * 127.0.0.1:8080/tb-parking-use/endPark---post
     * @param tbParkingUse
     * @return
     */
    @PostMapping(value = "endPark",consumes = "application/json")
    public HashMap<String, Object> endPark(@RequestBody TbParkingUse tbParkingUse){
        return  tbParkingUseService.endPark(tbParkingUse);
    }


    /**
     * 未购买停车位的用户支付停车费用之后-修改支付信息（金额，支付时间等）到tbParkingUse表中
     * 127.0.0.1:8080/tb-parking-use/endParkingFee --post
     * @param tbParkingUse
     * @return
     */
    @PostMapping(value = "endParkingFee",consumes = "application/json")
    public HashMap<String, Object> endParkingFee(@RequestBody TbParkingUse tbParkingUse){
        return  tbParkingUseService.endParkingFee(tbParkingUse);
    }

}

